<template>
  <div id="app">
    <van-cell-group>
      <van-cell v-for="item in list" :key="item.code" :title="item.title" is-link @click="push(item)"></van-cell>
    </van-cell-group>
  </div>
</template>

<script>
import { Cell, CellGroup } from 'vant'
import {nav, system} from 'MTHybrid'
// import {nav} from 'fzHybrid'

export default {
    name: 'Index',
    components: {
        [Cell.name]: Cell,
        [CellGroup.name]: CellGroup
    },
    data () {
        return {
            list: [
                { code: 'device', title: '设备', link: 'hy-device.html' },
                { code: 'system', title: '系统', link: 'hy-system.html' },
                { code: 'nav', title: '导航', link: 'hy-nav.html' },
                { code: 'app', title: 'app', link: 'hy-app.html' },
                { code: 'tab', title: 'tab', link: 'hy-tab.html' },
                { code: 'head', title: '顶栏', link: 'hy-head.html' },
                { code: 'page', title: 'page', link: 'hy-page.html' },
                { code: 'storage', title: '存储', link: 'hy-storage.html' },
                { code: 'payment', title: '支付', link: 'hy-payment.html' },
                { code: 'account', title: '账户', link: 'hy-account.html' },
                { code: 'file', title: '文件', link: 'hy-file.html' },
                { code: 'wxshare', title: '微信分享', link: 'hy-wxshare.html' },
                { code: 'cart', title: '购物车', link: 'hy-cart.html', hideTab: false }

            ]
        }
    },
    methods: {
        push (item) {
            console.info('agent' + navigator.userAgent)
            // if (link === 'hy-tab.html') {
            //     window.location.href = link
            //     return
            // }
            const link = item.link + '?' + (Math.random().toString(36).slice(2, 8))
            const hideTab = (item.hideTab === undefined ? true : item.hideTab)
            const os = system.os()
            if (os === 'android' || os === 'iOS') {
                nav.push({url: link, hideTab: hideTab})
            } else {
                window.location.href = link
            }
        }
    }
}
</script>

<style>
    @import '../../../static/css/index.css';
    #app {
        font-family: "Avenir", Helvetica, Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-align: center;
        color: #2c3e50;
        /* margin-top: 60px; */
        background-color: #eaeaea;
        width: 100%;
        height: 100%;
    }
</style>
